package Ticketing.test001;

/**
 * @Author czl
 * @Date 2024-03-21
 */
public class Film {
    private String name;

    private  int count;

    public Film (){

    }

    public Film (String name , int count){
        this.name = name ;
        this.count = count ;
    }

    public void sell(){
        while (this.count>0){
            synchronized (this){
                if (this.count>=1){
                    System.out.println(Thread.currentThread().getName()+"出售"+"《"+this.name+"》");

                    this.count--;

                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

        }
    }
}
